<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
	version="1.0"
	xmlns:php="http://php.net/xsl"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
		
	<!-- TAGS CLOUD -->
	<xsl:template match="tags" mode="block-tags-cloud">
		<div id="tags">
			<xsl:for-each select="tag">
				<a class="tag">
					<xsl:attribute name="href">
						<xsl:value-of select="concat ($baseURI, '/photos/tag/', value)" />
					</xsl:attribute>
					<xsl:attribute name="style">
						<xsl:value-of select="concat ('font-size: ', size, 'px')" />
					</xsl:attribute>
					<xsl:value-of select="value" />
				</a>
				<xsl:text> </xsl:text>
			</xsl:for-each>
		</div>
	</xsl:template>
	
	<!-- USER ALBUMS -->
	<xsl:template match="response" mode="block-user-albums">
		<xsl:if test="count (object) = 0">
			<xsl:choose>
				<xsl:when test="$module='users' and $method='profile'">
					<xsl:text>У пользователя нет фотоальбомов</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>У пользователя больше нет фотоальбомов</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
		
		<xsl:if test="count (object) != 0">
			<xsl:apply-templates select="object[@type='photoalbum']" />
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="object[@type='photoalbum']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		
		<div class="item">
			<div class="preview">
				<a href="{$baseURI}/photoalbum/{@id}">
					<img>
						<xsl:attribute name="src">
							<xsl:choose>
								<xsl:when test="property[@name='preview']/value = ''">
									<xsl:value-of select="$baseURI" />
									<xsl:text>/images/default-photoalbum-preview.png</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="concat ($baseURI, '/thumb_75_75', property[@name='preview']/value)" />
								</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
						<xsl:attribute name="alt">
							<xsl:value-of select="property[@name='title']/value" />
						</xsl:attribute>
					</img>
				</a>
			</div>
			<div class="info">
				<div class="title">
					<a href="{$baseURI}/photoalbum/{@id}">
						<xsl:value-of select="property[@name='title']/value" />
					</a>
				</div>
				
				<div class="stat">
					<p>
						<xsl:text>Создан </xsl:text>
						<xsl:value-of select="property[@name='date']/birthdate" />
						<br />
						<xsl:text>Обновлен </xsl:text>
						<xsl:value-of select="property[@name='update']/birthdate" />
					</p>
					<p>
						<xsl:value-of select="php:functionString ('XSLTGetNumWithCase', property[@name='count_photos']/value, 'фотография', 'фотографии', 'фотографий')" />
					</p>
				</div>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>